﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ServicesSheet_Property : System.Web.UI.Page
{
    private Srvtools.WebDataSet WMaster;

    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            InitializeComponent();
            Master.DataSource = WMaster;


            MasterPage_MasterPage master = (MasterPage_MasterPage)this.Page.Master;
            master.HelpHref = "~/Help/ServicesSheet/物业维修申请.htm";
            master.PageName = "物业维修申请";
            master.PicUrl = "";
            master.IntiBar();

        }

        //  this.InitData();



    }


    private void InitializeComponent()
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ServicesSheet_Property));
        this.WMaster = new Srvtools.WebDataSet();
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).BeginInit();
        // 
        // WMaster
        // 
        this.WMaster.Active = true;
        this.WMaster.AlwaysClose = true;
        this.WMaster.DeleteIncomplete = true;
        this.WMaster.Guid = null;
        this.WMaster.LastKeyValues = null;
        this.WMaster.Locale = new System.Globalization.CultureInfo("zh-CN");
        this.WMaster.PacketRecords = 100;
        this.WMaster.Position = -1;
        this.WMaster.RemoteName = "ServiceSheet.Services_Property";
        this.WMaster.ServerModify = true;
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).EndInit();

    }

    protected override void OnPreRender(EventArgs e)
    {
        string str = this.Request.Params["P"];
        if (str == "2" || str == "3" || str == "4")
        {
            // Master.ExecuteSync(WebFormView2);
            // Master.ExecuteSync(WebFormView3);
            DataBind();
        }
        this.InitData();
        base.OnPreRender(e);
    }


    protected object GetEmpId()
    {
        String str = Srvtools.CliUtils.GetValue("_UserCode")[1].ToString();
        str = int.Parse(str).ToString();
        return str;
    }

    private void InitData()
    {
        if (this.Request.Params["P"] == "1")
        {
            this.WebFormView2.Visible = false;
            this.WebFormView3.Visible = false;
        }
        if (this.Request.Params["P"] == "2")
        {
            this.WebFormView3.Visible = false;
            this.FLWebNavigator1.NavControls.RemoveAt("Approve");
        }
        else if (this.Request.Params["P"] == "3")
        {
            this.FLWebNavigator1.NavControls.RemoveAt("Approve");
            Button btnEdit = (Button)this.WebFormView2.FindControl("btnEdit");
            if (btnEdit != null) btnEdit.Visible = false;

            Button btnFinishRep = (Button)this.WebFormView2.FindControl("btnFinishRep");
            if (btnFinishRep != null) btnFinishRep.Visible = false;

            Button btnFinishFQb = (Button)this.WebFormView3.FindControl("btnFinishFQ");
            if (btnFinishFQb != null) btnFinishFQb.Visible = true;

        }
        else if (this.Request.Params["P"] == "4")
        {
            Button btnEdit = (Button)this.WebFormView2.FindControl("btnEdit");
            if (btnEdit != null) btnEdit.Visible = false;

            Button btnFinishRep = (Button)this.WebFormView2.FindControl("btnFinishRep");
            if (btnFinishRep != null) btnFinishRep.Visible = false;

            Button btnFinishFQb = (Button)this.WebFormView3.FindControl("btnFinishFQ");
            if (btnFinishFQb != null) btnFinishFQb.Visible = false;

            Button btnEdit3 = (Button)this.WebFormView3.FindControl("btnEdit");
            if (btnEdit3 != null) btnEdit3.Visible = false;
        }
        else
        {
            this.WebFormView2.Visible = false;
            this.WebFormView3.Visible = false;
        }
    }

    protected void WebFormView2_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            this.WebFormView2.UpdateItem(false);
            Master.ApplyUpdates();
        }

    }

    protected void WebFormView3_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        if (e.CommandName == "Save")
        {
            this.WebFormView3.UpdateItem(false);
            this.Master.ApplyUpdates();
        }
    }

    protected void btnFinishRep_Click(object sender, EventArgs e)
    {
        FLWebNavigator1.Approve();
    }
    protected void btnFinishFQ_Click(object sender, EventArgs e)
    {
        FLWebNavigator1.Approve();
    }
}
